package com.chentf.reggie.demo;

import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/**
 * @author chentengfei
 * @desc ...
 * @date 2023-03-16 09:29:13
 */
public class Test01 {

    public static int funx(char[] source, int sourceOffset, int sourceCount, char[] target, int targetCount) {

        if (targetCount == 0) {

            return 0;

        }

        char first = target[0];

        int max = sourceOffset + (sourceCount - targetCount);

        for (int i = sourceOffset + 0; i <= max; i++) {

            if (source[i] != first) {

                while (++i <= max && source[i] != first){

                };

            }

            /* Found first character, now look at the rest of v2 */

            if (i <= max) {

                int j = i + 1;

                int end = j + targetCount - 1;

                for (int k = 0 + 1; j < end && source[j]== target[k]; j++, k++){

                };

                if (j == end) {

                    return i - sourceOffset;

                }

            }

        }

        return -1;
    }

    private static int func(int x,int y) {
        if(x+y<=5) {
            return 2 * y;
        }
        if(y<=3) {
            return  x+y;
        }
        return func(x-2,y-2);
    }

    public static void main(String[] args) {
//        char[] source = "abcdefghijklm".toCharArray();
//        int sourceOffset =1;
//        int sourceCount = 12;
//        char[] target = "efghijk".toCharArray();
//        int targetCount = 6;
//        System.out.println(funx(source,sourceOffset,sourceCount,target,targetCount));

        System.out.println(func(9, 9));



    }
}
